package com.hk.webapp.controller.admin;

import com.hk.webapp.annotations.AllowAnonymous;
import com.hk.webapp.annotations.SkipPermission;
import com.hk.webapp.utils.ImageUtil;
import com.hk.webapp.utils.encryptions.DESUtils;
import com.hk.webapp.vo.CaptchaVo;
import com.hk.webapp.vo.ResultVo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@SkipPermission
@RestController
public class VerifyCodeController extends AdminBaseController {

    @AllowAnonymous
    @PostMapping("/VerifyCode/NumberVerifyCode")
    public ResultVo numberVerifyCode() throws Exception{
        ImageUtil imageUtil = new ImageUtil(100, 40, 5, 30);
        String verifyCodeBase64 = imageUtil.writeBase64();
        String code = imageUtil.getCode();
        String pwdCodeEncrypt = DESUtils.encrypt(code);
        CaptchaVo captchaVo = new CaptchaVo();
        captchaVo.setData(verifyCodeBase64);
        captchaVo.setCarry(pwdCodeEncrypt);
        return ResultVo.createBySuccessData(captchaVo);
    }

}
